﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Warehouse.ErrorCode;
using Warehouse.Api.Write.AllCation.Command.Breakage;
using Microsoft.AspNetCore.Authorization;

namespace Warehouse.Api.Write.Controllers
{
    /// <summary>
    /// 破损的接口
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class BreakageController : ControllerBase
    {
        public readonly IMediator mediator;

        public BreakageController(IMediator mediator)
        {
            this.mediator = mediator;
        }


        /// <summary>
        /// 添加破损的记录
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<int>> AddBreakage(AddBreakageCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 报损单删除的接口
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<int>> DeleteBreakage(DeleteBreakageCommand request)
        {
            return mediator.Send(request);
        }

        /// <summary>
        /// 破损的更新接口
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPut]
        public Task<ApiResult<int>> UpdateBreakage(UpdateBreakageCommand request)
        {
            return mediator.Send(request);
        }

    }
}
